<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Fashion Consulting Company</title>
	
	<link href="/css/all.css" type="text/css" rel="stylesheet" />
	<link href="/css/smoothness/jquery-ui-1.8.17.custom.css" type="text/css" rel="stylesheet" />
	<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="css/ie.css" media="screen"/><![endif]-->
	
	<script type="text/javascript" src="/cf/js/jquery.min.js"></script>
	<script type="text/javascript" src="/js/jquery-ui-1.8.17.custom.min.js"></script>
	<script type="text/javascript" src="/cf/js/jquery.ui.datepicker-ru.js"></script>
	<script type="text/javascript" src="/cf/js/smart.min.js"></script>
	<script type="text/javascript" src="/cf/js/utils.js"></script>
	<script type="text/javascript" src="/js/main.js"></script>
	<script type="text/javascript" src="/js/controls.js"></script>
	<script type="text/javascript" src="/js/jquery.mousewheel.min.js"></script>
</head>
<body>
	<script>
		var groups = {$groups};
		var brands = {$brands};
		var seasons = {$seasons};
		var closets = {$closets};
	
		var show = 0;
		
		function call(url, params)
		{
			if (++show==1) { $('#wait').show(); }
			return $.post('/cf/call/'+url, params, function(data, textStatus, jqXHR) {  }, 'json')
				.error( 
					function(jqXHR,textStatus,errorThrown) { 
						var sParams = '';
						for (var p in params) {
							sParams += ' ' + p + '=' + params[p];	//dump to string
						}
						alert('Error:'+url+' '+sParams);
					}					
				).done( function() { 
					if (!--show) { $('#wait').hide(); }
				} );
		}
		
		function logout() {
			call('user.logout').done(function() {
				location = '/';
			} );
		}
		
		function changeClient(id) {
			clientId = id;
			call('session.set',{ 'name':'clientID', 'value':clientId });
			$.each(clients,function(i,val) { 
				if (val[1] == clientId) {
					$('#client_name').html(val[2]);
					return false;
				}
			})
		}
		
		function updateCart() {
			{if $isStylist}
				call('admin.getList',{ 'id':'cart_all_clients', 'params':{ 'stylistId':stylistId } }).done(function(cartTotal){ showCartContents(cartTotal); });
			{else}
				call('admin.getList',{ 'id':'cart', 'params':{ 'clientId':clientId } }).done(function(cartTotal){ showCartContents(cartTotal); });
			{/if}
		}
		
		function showCartContents(cartTotal) {
			$('#cart dl').html( 
				$('#cart_tpl').html().fetch({ 'total_count':cartTotal.length ? cartTotal[0][1] : 0, 'total_price':cartTotal.length ? cartTotal[0][2] : 0 })
			);
		}
		
		function overlay() {
			$('#overlay')
				.css('height',$(document).height())
				.css('width',$(document).width())
				.show();
		}
		
		function popup(title, tpl, onCancel) {
			overlay();
			
			$('#popupBox')
				.html(
					$('#popup_tpl').html().fetch( {
						'title': title,
						'tpl': tpl
					} )
				)
				.show();
			
			$('#popupBox')
				.css('top', Math.max($(window).height()/2-$('#popupBox').height()/2,0))
				.css('left', $(window).width()/2-$('#popupBox').width()/2)
				.data('onCancel',onCancel);
			
			$('#popupBox').draggable({ 'handle': '.popup-t' });
			
			$('#popupBox img').load(function(){
				$('#popupBox').css('top', $(window).height()/2-$('#popupBox').height()/2).css('left', $(window).width()/2-$('#popupBox').width()/2);
			});
			
			return $('#popupBox');
		}
		
		function hidePopup(state) {
			$('#popupBox').hide();
			$('#overlay').hide();
			if (!state) {
				var onCancel = $('#popupBox').data('onCancel');
				if (onCancel) {
					onCancel();
				}
			}
		}
		
		function openShopItem(id, onChange) {
			if (isStylist) {
				openShopItemStylist(id, onChange);
			} else {
				openShopItemClient(id);
			}
		}
		
		function openShopItemStylist(id, onChange)
		{
			call('admin.findByKey',{ 'vid':'shop_items', 'k':id, 'params':{ 'clientId':clientId } }).done(function(product){
				call('admin.findByKey',{ 'vid':'ordered_shop_items', 'k':id }).done(function(orders){
					popup(
						'Стол заказов',
						$('#shop_product_stylist_tpl').html().fetch(product),
						function(){ 
							$('#popupBox .file form').tmpFile('cancel'); 
						}
					);
					
					var menuItems = [];
					if (!orders.ordered) {
						menuItems.push([	
							'Удалить',
							function(){ 
								call('admin.doDelete',{ 'aid':'shop_item_del', 'params':{ 'id':id } }).done(function(){
									if (onChange) {
										onChange();
									}
								});
								hidePopup('ok'); 
							}
						]);
					}
					menuItems.push([	
						'Удалить изображение',
						function() { $('#popupBox .image div').gallery('del'); }
					]);
					
					$('#popupBox .title .all-link').popUpMenu({
						'onShow': function(a){ a.addClass('active'); },
						'onHide': function(a){ a.removeClass('active'); },
						'items': menuItems
					});
					
					$('#popupBox .image div').gallery({
						'item_id': id,
						'prev': '#popupBox .btn1',
						'next': '#popupBox .btn2',
						'open': '#popupBox .btn3, #popupBox .image'
					});
					
					$('#select_category').dropDown({ 'options':groups,  'value':product.groupid,  'input_name':'groupid' });
					$('#select_brand').dropDown({    'options':brands,  'value':product.brand,    'input_name':'brand'   });
					$('#select_season').dropDown({   'options':seasons, 'value':product.season,   'input_name':'season'  });

					$('#popupBox .file form').tmpFile({ 'onAdd': function(path) { $('#popupBox .image div').gallery('add',path).gallery('last'); } });
					
					$('#popupBox').find('#recommend').click(function(e){
						call(
							'admin.doAction',{ 
								'id':'recommend', 
								'params':{ 'clientId':clientId, 'stylistId':stylistId, 'itemId':id } 
							}
						).done(function(){ hidePopup(); })
					});
					
					$('#popupBox').find('#unrecommend').click(function(e){
						call(
							'admin.doAction',{ 
								'id':'unrecommend', 
								'params':{ 'clientId':clientId, 'stylistId':stylistId, 'itemId':id } 
							}
						).done(function(){ hidePopup(); })
					});
					
					$('#newBrand').popup({
						'onShow': function(target){ target.find('input[name=name]').val('').focus(); },
						'onOk': function(params) {
							if (params.name) {
								call('admin.doAction',{ id:'manufacturer_add', 'params':{ 'name':params.name, 'code':'', 'descr':'' } }).done(function(newId){
									call('admin.getList',{ 'id':'manufacturers',  'sort':{ 'name':'a' } }).done(function(items){
										brands = items;
										$('#select_brand').dropDown('options',brands).dropDown('value',newId);
									})
								});
								
							}
						}
					});
					$('#add-brand').on('click.popup',function(e){
						e.preventDefault();
						$('#newBrand').popup('show', $('#select_brand .selectButton').offset().top, $('#select_brand .selectButton').offset().left);
					});
					
					
					$('#newCategory').popup({
						'onShow': function(target){ target.find('input[name=name]').val('').focus(); },
						'onOk': function(params) {
							if (params.name) {
								call('admin.doAction',{ id:'categories.add', 'params':{ 'name':params.name } }).done(function(newId){
									call('admin.getList',{ 'id':'categories' }).done(function(items){
										groups = items;
										$('#select_category').dropDown('options',groups).dropDown('value',newId);
									})
								});
							}
						}
					});
					$('#add-category').on('click.popup',function(e){
						e.preventDefault();
						$('#newCategory').popup('show', $('#select_category .selectButton').offset().top, $('#select_category .selectButton').offset().left);
					});
					
					
					$('#popupBox #closet_item form:nth-child(2)').submit(function(e){
						e.preventDefault();
					
						var params = $(this).serializeObject();
						
						if (!params.id) {
							delete params.id;
						}
						if (!params.name) {
							params.name = ' ';	//name is not mandatory
						}
						
						$('#popupBox .file form').tmpFile('save','product_images');
						
						var imagesCount = 1;
						$('#popupBox .image div img').each(function(i){ 
							params['image'+(imagesCount++)] = $(this).attr('image').replace(/^tmp/,'product_images'); 
						});
						for (var i=imagesCount; i<16; ++i) {
							params['image'+i] = '';
						}
						call('admin.doAction',{ 'id':('id' in params)?'shop_item_edit':'shop_item_add', 'params':params }).done(function(){
							if (onChange) {
								onChange();
							}
						});

						hidePopup('ok');
					});
				});
			});
		}

		function openShopItemClient(id)
		{
			call('admin.findByKey',{ 'vid':'shop_items', 'k':id, 'params':{ 'clientId':clientId } }).done(function(product){
				popup(
					'Стол заказов',
					$('#shop_product_client_tpl').html().fetch({ 'product':product })
				);
				
				$('#popupBox .image div').gallery({
					'item_id': id,
					'prev': '#popupBox .btn1',
					'next': '#popupBox .btn2',
					'open': '#popupBox .btn3, #popupBox .image'
				});
				
				$('#popupBox').find('#buy').click(function(e){
					call('admin.doAction',{ 'id':'order_product', 'params':{ 'id':id, 'clientId':clientId } }).done(function(){ updateCart(); hidePopup(); })
				});
			});
		}
		
		function openClosetItem(id, onChange) {
			call('admin.findByKey',{ 'vid':'closet_items', 'k':id, 'params':{ 'clientId':clientId } }).done(function(item){
				popup(
					'Шкаф', 
					$('#closet_item_tpl').html().fetch($.extend({ 'isStylist':{$isStylist} },item)),
					function(){ 
						$('#popupBox .file form').tmpFile('cancel'); 
					}
				);
				
				$('#popupBox .title .all-link').popUpMenu({
					'onShow': function(a){ a.addClass('active'); },
					'onHide': function(a){ a.removeClass('active'); },
					'items': [  
						[	'Удалить',
							function(){ 
								call('admin.doDelete',{ 'aid':'closet_item_del', 'params':{ 'id':id } }).done(function(){
									if (onChange) {
										onChange();
									}
								});
								hidePopup('ok'); 
							}
						],
						[	'Удалить изображение',
							function() { $('#popupBox .image div').gallery('del'); }
						]
					]
				});
				
				$('#popupBox .image div').gallery({
					'item_id': id,
					'prev': '#popupBox .btn1',
					'next': '#popupBox .btn2',
					'open': '#popupBox .btn3, #popupBox .image'
				});
				
				$('#select_category').dropDown({ 'options':groups,  'value':item.groupid,  'input_name':'groupid' });
				$('#select_brand').dropDown({    'options':brands,  'value':item.brand,    'input_name':'brand'   });
				$('#select_season').dropDown({   'options':seasons, 'value':item.season,   'input_name':'season'  });
				$('#select_closet').dropDown({   'options':closets, 'value':item.closet,   'input_name':'closet'  });
				$('#select_date').dateDown({ 'value':item.bought_date_short, 'input_name':'bought' });

				$('#popupBox .file form').tmpFile({ 'onAdd': function(path) {	$('#popupBox .image div').gallery('add',path).gallery('last'); } });
				
				$('#newCloset').popup({
					'onShow': function(target){ target.find('input[name=name]').val('').focus(); },
					'onOk': function(params) {
						if (params.name) {
							call('admin.doAction',{ id:'closet.add', 'params':{ 'owner_id':clientId, 'name':params.name } }).done(function(newId){
								call('admin.getList',{ 'id':'closets',  'filter':{ 'owner_id':clientId } }).done(function(items){
									closets = items;
									$('#select_closet').dropDown('options',closets).dropDown('value',newId);
								})
							});
						}
					}
				});
				$('#add-closet').on('click.popup',function(e){
					e.preventDefault();
					$('#newCloset').popup('show', $('#select_closet .selectButton').offset().top, $('#select_closet .selectButton').offset().left);
				});
				
				
				$('#newBrand').popup({
					'onShow': function(target){ target.find('input[name=name]').val('').focus(); },
					'onOk': function(params) {
						if (params.name) {
							call('admin.doAction',{ id:'manufacturer_add', 'params':{ 'name':params.name, 'code':'', 'descr':'' } }).done(function(newId){
								call('admin.getList',{ 'id':'manufacturers',  'sort':{ 'name':'a' } }).done(function(items){
									brands = items;
									$('#select_brand').dropDown('options',brands).dropDown('value',newId);
								})
							});
							
						}
					}
				});
				$('#add-brand').on('click.popup',function(e){
					e.preventDefault();
					$('#newBrand').popup('show', $('#select_brand .selectButton').offset().top, $('#select_brand .selectButton').offset().left);
				});
				
				
				$('#newCategory').popup({
					'onShow': function(target){ target.find('input[name=name]').val('').focus(); },
					'onOk': function(params) {
						if (params.name) {
							call('admin.doAction',{ id:'categories.add', 'params':{ 'name':params.name } }).done(function(newId){
								call('admin.getList',{ 'id':'categories' }).done(function(items){
									groups = items;
									$('#select_category').dropDown('options',groups).dropDown('value',newId);
								})
							});
						}
					}
				});
				$('#add-category').on('click.popup',function(e){
					e.preventDefault();
					$('#newCategory').popup('show', $('#select_category .selectButton').offset().top, $('#select_category .selectButton').offset().left);
				});
				
				
				
				$('#popupBox #closet_item form:nth-child(2)').submit(function(e){
					e.preventDefault();
				
					var params = $.extend({ 'clientId': clientId }, $(this).serializeObject());
					if (!params.id) {
						delete params.id;
					}
					if (!params.name) {
						params.name = ' ';	//name is not mandatory
					}
					
					$('#popupBox .file form').tmpFile('save','product_images');
					
					var imagesCount = 1;
					$('#popupBox .image div img').each(function(i){ 
						params['image'+(imagesCount++)] = $(this).attr('image').replace(/^tmp/,'product_images'); 
					});
					for (var i=imagesCount; i<16; ++i) {
						params['image'+i] = '';
					}
					call('admin.doAction',{ 'id':('id' in params)?'closet_item_edit':'closet_item_add', 'params':params }).done(function(){
						if (onChange) {
							onChange();
						}
					});
					
					hidePopup('ok');
				});
			});
		}
		
		function openClient() {
			call('admin.findByKey',{ 'vid':'clients', 'k':clientId }).done(function(client){
				popup(
					'Клиент',
					$('#client_params_tpl').html().fetch(client)
				);
				
				$('#popupBox #client_params form').submit(function(e){
					e.preventDefault();
					var params = $.extend({ 'id':clientId, 'silhouette':'' }, $(this).serializeObject());
					call('admin.doAction',{ id:'client.params', 'params':params });
					hidePopup('ok');
				});
			});
		}
		
		{literal}
		jSmart.prototype.getTemplate = function(id) {
			return $('#'+id).html();
		}
		
		jSmart.prototype.registerPlugin(
			'function', 
			'price_fmt', 
			function(params, data)
			{
				var price = new String(params.price);
				if (price.indexOf('.')>=0) {
					price = price.slice(0,price.length-3)
				}
				return price.replace(/(\d)(\d{6})$/,'$1&nbsp;$2').replace(/(\d)(\d{3})$/,'$1&nbsp;$2');
			}
		);
		
		jSmart.prototype.registerPlugin(
			'modifier', 
			'prepend0', 
			function(s)
			{
				s = new String(s);
				return s.length==1 ? '0'+s : s;
			}
		);
		{/literal}
		

		$(function() {
			$(document).keyup(function(e) {
				if (e.keyCode == 27) { hidePopup(); }   // esc
			});
			
			$('.checkboxArea').click(function(e){
				$(e.target).toggleClass('checked');
			});
		});
	</script>

	{literal}
	<script id='opener_tpl' type="text/x-jsmart-tmpl">
		<ul>
			{foreach $items as $item}
				<li><a href="#" value='{$item[$iID|default:1]}'>{$item[$iName|default:2]}</a></li>
			{/foreach}
		</ul>
	</script>
	
	<script id='popup_tpl' type="text/x-jsmart-tmpl">
		<div class="popup-t">
			<h2>{$title}</h2>
			<a href="#" class="close" onclick="hidePopup(); return false;">ЗАКРЫТЬ</a>
		</div>
		<div class="popup-c">
			{$tpl}
		</div>
		<div class="popup-b"></div>
	</script>	

	<script id='dropdown_tpl' type="text/x-jsmart-tmpl">
		<div class='selectArea'>
			{if $input_name} 
				<input type=hidden name='{$input_name}' value='{$value}' />
			{/if}
			<span class='left'></span>
			<span class='disabled'></span>
			<span class='center'>&nbsp;</span>
			<a class="selectButton" href='#'></a>
			<div class='drop_down_options'>
			{foreach $options as $option}
				<a href='#' value='{$option[1]}' {if $option[1]==$value}class='active'{/if}>{$option[2]}</a>
			{/foreach}	
			</div>
		</div>
	</script>
	
	<script id='datedown_tpl' type="text/x-jsmart-tmpl">
		<input type=text class='date_down' name='{$input_name}' value='{$day|prepend0}.{$month|prepend0}.{$year|prepend0}' />
	</script>	
	
	<script id='login_tpl' type="text/x-jsmart-tmpl">
		<form method=post>
			<table style='padding-left:180px;'>
				<tr>
					<td style="text-align:right;">
						Логин: 
					</td>
					<td>
						<input type=text name='log' size=30 />
					</td>
				</tr>
				<tr>
					<td style="text-align:right;">
						Пароль:
					</td>
					<td>
						<input type=password name='pwd' size=30 />
					</td>
				</tr>
				<tr>
					<td colspan=2>
						<input type=checkbox name='remember' /> Запомнить
					</td>
				</tr>
				<tr>
					<td colspan=2 style="text-align:right;">
						<button type=submit class='submit'>Войти</button>
					</td>
				</tr>
			</table>
		</form>
	</script>
	
	<script id='shop_product_client_tpl' type="text/x-jsmart-tmpl">
		<div id='shop_item'>
			<div class="btn-box">
				<ul class="btn-list" id='image_browse'>
					<li><a class="btn1 inactive" href="#" title='Предыдущее изображение'>Previous Image</a></li>
					<li><a class="btn2 inactive" href="#" title='Следующее изображение'>Next Image</a></li>
					<li><a class="btn3" href="#" title='Открыть изображение' target=_blank style='display:none;'>Open Image</a></li>
				</ul>
			</div>
			<div class='image'>
				<div></div>
			</div>
			
			<div class='price'>{price_fmt price=$product.price}</div>
			
			<div class='param'>Название: <span>{$product.name}</span></div>
			<div class='param'>Бренд: <span>{$product.brandname}</span></div>
			<div class='param'>Сезон: <span>{$product.season_name}</span></div>
			<div class='param'>Добавлено: <span>{$product.added_date}</span></div>

			<div style='text-align:right;padding:20px; clear:both;'>
				<button id='buy'>ЗАКАЗАТЬ</button>
			</div>
		</div>
	</script>
	
	
	<script id='shop_product_stylist_tpl' type="text/x-jsmart-tmpl">
		<div class="title">
			<a class="all-link" href="#">ВСЕ ДЕЙСТВИЯ</a>
		</div>
		<div id='closet_item'>
			<div class="btn-box">
				<ul class="btn-list" id='image_browse'>
					<li><a class="btn1 inactive" href="#" title='Предыдущее изображение'>Previous Image</a></li>
					<li><a class="btn2 inactive" href="#" title='Следующее изображение'>Next Image</a></li>
					<li><a class="btn3" href="#" title='Открыть изображение' target=_blank style='display:none;'>Open Image</a></li>
				</ul>
				<div class="file file-input-js-active">
					<form action='/cf/call/tmp.add' target='tmp_image' method=post enctype='multipart/form-data'>
						<input type=file name='f' class="file-input-area" style="opacity: 0;">
						<a class="button" href="#">ЗАГРУЗИТЬ ФОТО</a>
					</form>
				</div>
			</div>
		<form>
			<input type=hidden name='id' value='{$id}' />
			<div class='image'>
				<div></div>
			</div>
			
			<div class='columns'>
				<div class="column1">
					<div class="row">
						<label>Название:</label>
						<div class="text">
							<input type=text name='name' value='{$name}'>
						</div>
					</div>
					<div class="row">
						<label>Бренд:</label>
						<div class="select-holder" id='select_brand'></div>
						<a href="#" id='add-brand' class="add-link" onclick="return false;" title='Добавить'></a>
					</div>
					<div class="row">
						<label>Цена:</label>
						<div class="text">
							<input type=text name='price' value='{$price}'>
						</div>
					</div>
				</div>
				<div class="column2">
					<div class="row">
						<label>Категория:</label>
						<div class="select-holder" id='select_category'></div>
						<a href="#" id='add-category' class="add-link" onclick="return false;" title='Добавить'></a>
					</div>
					<div class="row">
						<label>Сезон:</label>
						<div class="select-holder" id='select_season'></div>
					</div>
					<div class="row">
						<label>Добавлен:</label>
						<div class='static'>{$added_date|default:'сейчас'}</div>
					</div>
				</div>
			</div>
			<div class="row2">
				<label>Описание:</label>
				<div class="textarea-holder">
					<textarea name='descr' rows="3" cols="80">{$descr|replace:'null':''}</textarea>
				</div>
			</div>
			<div style="text-align:right; position:relative;">
				<span style='display:block; position:absolute; top:0px; left:20px;'>
				{if $recommended==1}
					<span style='color: #666; font:13px Arial; font-weight: bold;'>РЕКОМЕНДОВАНО</span>&nbsp;&nbsp; <button id='unrecommend'>Отменить</button>
				{else}
					<button id='recommend'>Рекомендую</button>
				{/if}
				</span>
				<button type=submit>Сохранить</button>
			</div>
		</form>
		</div>
	</script>
	
	
	<script id='closet_item_tpl' type="text/x-jsmart-tmpl">
		<div class="title">
			<a class="all-link" href="#">ВСЕ ДЕЙСТВИЯ</a>
		</div>
		<div id='closet_item'>
			<div class="btn-box">
				<ul class="btn-list" id='image_browse'>
					<li><a class="btn1 inactive" href="#" title='Предыдущее изображение'>Previous Image</a></li>
					<li><a class="btn2 inactive" href="#" title='Следующее изображение'>Next Image</a></li>
					<li><a class="btn3" href="#" title='Открыть изображение' target=_blank style='display:none;'>Open Image</a></li>
				</ul>
				<div class="file file-input-js-active">
					<form action='/cf/call/tmp.add' target='tmp_image' method=post enctype='multipart/form-data'>
						<input type=file name='f' class="file-input-area" style="opacity: 0;">
						<a class="button" href="#">ЗАГРУЗИТЬ ФОТО</a>
					</form>
				</div>
			</div>
		<form>
		<input type=hidden name='id' value='{$id}' />
			<div class='image'>
				<div></div>
			</div>
			
			<div class='columns'>
				<div class="column1">
					<div class="row">
						<label>Название:</label>
						<div class="text">
							<input type=text name='name' value='{$name}'>
						</div>
					</div>
					<div class="row">
						<label>Бренд:</label>
						<div class="select-holder" id='select_brand'></div>
						{if $isStylist}<a href="#" id='add-brand' class="add-link" onclick="return false;" title='Добавить'></a>{/if}
					</div>
					<div class="row">
						<label>Шкаф:</label>
						<div class="select-holder" id='select_closet'></div>
						<a href="#" id='add-closet' class="add-link" onclick="return false;" title='Добавить'></a>
					</div>
				</div>
				<div class="column2">
					<div class="row">
						<label>Категория:</label>
						<div class="select-holder" id='select_category'></div>
						{if $isStylist}<a href="#" id='add-category' class="add-link" onclick="return false;" title='Добавить'></a>{/if}
					</div>
					<div class="row">
						<label>Сезон:</label>
						<div class="select-holder" id='select_season'></div>
					</div>
					<div class="row">
						<label>Дата покупки:</label>
						<div class="select-holder" id='select_date'></div>
					</div>
				</div>
			</div>
			<div class="row2">
				<label>Описание:</label>
				<div class="textarea-holder">
					<textarea name='descr' rows="3" cols="80">{$descr|replace:'null':''}</textarea>
				</div>
			</div>
			<div style="text-align:right;">
				<button type=submit>Сохранить</button>
			</div>
		</form>
		</div>
	</script>
	
	<script id='cart_tpl' type="text/x-jsmart-tmpl">
		{if $total_count>0}
			<dt><span>{$total_count}</span> товаров -</dt>
			<dd><span>{price_fmt price=$total_price}</span> рублей</dd>
		{else}
			нет
		{/if}
	</script>
	
	<script id='client_params_tpl' type="text/x-jsmart-tmpl">
		<div id='client_params'>
			<form>
				<fieldset>
					<div class="column1">
						<div class="heading">
							<h2>КОНТАКТЫ</h2>
						</div>
						<div class="section personal">
							<div class="row">
								<label>Телефон:</label>
								<div class="text">
									<input type="text" name='phone' value='{$phone|default:''}' />
								</div>
							</div>
							<div class="row">
								<label>Skype:</label>
								<div class="text">
									<input type="text" name='skype' value='{$skype|default:''}' />
								</div>
							</div>
							<div class="row">
								<label>E-mail:</label>
								<div class="text">
									<input type="text" name='email' value='{$email|default:''}' />
								</div>
							</div>
						</div>
						<div class="heading">
							<h2>РАЗМЕРЫ</h2>
						</div>
						<div class="section sizes">
							<div class="col1">
								<div class="row">
									<label>Рост:</label>
									<div class="text">
										<input type=text name='height' value='{$height|default:''}' />
									</div>
								</div>
								<div class="row">
									<label>Грудь:</label>
									<div class="text">
										<input type=text name='size_chest' value='{$size_chest|default:''}' />
									</div>
								</div>
							</div>
							<div class="col2">
								<div class="row">
									<label>Талия:</label>
									<div class="text">
										<input type=text name='size_waist' value='{$size_waist|default:''}' />
									</div>
								</div>
								<div class="row">
									<label>Бедра:</label>
									<div class="text">
										<input type=text name='size_hips' value='{$size_hips|default:''}' />
									</div>
								</div>
							</div>
							<div class="col3">
								<div class="row">
									<label>Обувь:</label>
									<div class="text">
										<input type=text name='size_shoe' value='{$size_shoe|default:''}' />
									</div>
								</div>
								<div class="row">
									<label>Палец:</label>
									<div class="text">
										<input type=text name='size_finger' value='{$size_finger|default:''}' />
									</div>
								</div>
							</div>
						</div>
						<div style="text-align:right; clear:both;">
							<button type=submit>СОХРАНИТЬ</button>
						</div>
					</div>
					<!--
					<div class="column2">
						<h2>СИЛУЭТ</h2>
						<div class="img-holder">
							<img src="images/img.jpg" alt="" width="200" height="200" />
						</div>
						<div class="file">
							<input class="file-input-area" type="file" value="ЗАГРУЗИТЬ ФОТО" />
							<a href="#" class="button">ЗАГРУЗИТЬ ФОТО</a>
						</div>
					</div>
					-->
				</fieldset>
			</form>
		</div>
	</script>
	
	{/literal}
	
		
	<div id='popupBox' class='popup'></div>
	<div id='overlay' class="ui-widget-overlay"></div>
	
	<script>
		var clientId = {$clientId};
		var stylistId = {$stylistId};
		var isStylist = {$isStylist};
		
		var clients = {$clients};
		
		{if $user}
		$(function() {
			changeClient(clientId);
			updateCart();
		});
		{/if}
	</script>

	<div id='wait'><img src='/images/wait.gif'/></div>
	
	<div id="wrapper">
		<div id="header">
			<a href='/'><img src='/images/logo.png' /></a>
			{if $user}
			<div class="panel">
				<div class="entry-box">
					<a href="#" onclick="logout();return false;">{$user->name()}</a>
					{if $isStylist}<a href='#' style='display:block; padding-left:24px; background: none;' id='client_name' onclick='openClient(); return false;'></a>{/if}
				</div>
				<div class="basket-box" id='cart'>
					<a href="/orders">Заказы</a>
					<dl>
					</dl>
				</div>
			</div>
			<ul id="nav">
				{foreach $topMenu as $m}
					<li class='{if $m[''].id==$currTopPage.id}active{/if}'><a href="{$m[''].link}">{$m[''].menu_name}</a></li>
				{/foreach}
			</ul>
			{/if}
		</div>
		
		<div id="main">
			{include $tpl}
		</div>
		<div id="footer">
			<p class="copyright">2012 «Fashion Consulting Company» All rights reserved</p>
			<ul>
				<li><a href="/privacy">Конфедициальность</a></li>
				<li><a href="/terms">Условия использования</a></li>
			</ul>
		</div>
	</div>
	
	<form class='pop-up' id='newCloset'>
		<input type=text name='name' style='width:210px;' />
	</form>
	
	<form class='pop-up' id='newBrand'>
		<input type=text name='name' style='width:210px;' />
	</form>
	
	<form class='pop-up' id='newCategory'>
		<input type=text name='name' style='width:210px;' />
	</form>
	
	<iframe name='tmp_image' style='display:none;'></iframe>
</body>
</html>